﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;
using System.Xml;
using XMLSpreadGear.Templates;

namespace XMLSpreadGear.Headers
{
    public class DocumentProperties:BaseElement
    {
        private string strAuthor;

        public string Author
        {
            get { return strAuthor; }
            set { strAuthor = value; }
        }
        private string strCreated;

        public string Created
        {
            get { return strCreated; }
            set { strCreated = value; }
        }
        private string strLastSaved;

        public string LastSaved
        {
            get { return strLastSaved; }
            set { strLastSaved = value; }
        }
        private string strversion;

        public string Version
        {
            get { return strversion; }
            set { strversion = value; }
        }

        public DocumentProperties(string strLocalName)
            : base(strLocalName)
        {
        }
        public DocumentProperties(string strLocalName, string strauthor, string created, string lastsaved, string version)
            : this(strLocalName)
        {
            this.strAuthor = strauthor;
            this.strCreated = created;
            this.strLastSaved = lastsaved;
            this.strversion = version;
        }
        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if (!string.IsNullOrEmpty(this.Author))
            {
                dic.Add("Author", AddGenericElement("Author",this.Author));
            }

            if (!string.IsNullOrEmpty(this.Created))
            {
                dic.Add("Created", AddGenericElement("Created", this.Created));
            }

            if (!string.IsNullOrEmpty(this.LastSaved))
            {
                dic.Add("LastSaved", AddGenericElement("LastSaved",this.LastSaved));
            }

            if (!string.IsNullOrEmpty(this.Version))
            {
                dic.Add("Version", AddGenericElement("Version",this.Version));
            }

            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(!string.IsNullOrEmpty(this.LocalName))
                dic.Add("Name", this.LocalName);
            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }
    }
}
